package com.td.module.cooperative.dal.mysql.partner;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.cooperative.controller.admin.partner.vo.CountPartnerRespVO;
import com.td.module.cooperative.controller.admin.partner.vo.PartnerExportReqVO;
import com.td.module.cooperative.controller.admin.partner.vo.PartnerPageReqVO;
import com.td.module.cooperative.dal.dataobject.partner.PartnerDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 合作伙伴 Mapper
 *
 * @author wangxx
 */
@Mapper
public interface PartnerMapper extends BaseMapperX<PartnerDO> {

    default PageResult<PartnerDO> selectPage(PartnerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PartnerDO>()
                .likeIfPresent(PartnerDO::getPartnerName, reqVO.getPartnerName())
                .eqIfPresent(PartnerDO::getPartnerType, reqVO.getPartnerType())
                .eqIfPresent(PartnerDO::getPartnerIntro, reqVO.getPartnerIntro())
                .eqIfPresent(PartnerDO::getPartnerImg, reqVO.getPartnerImg())
                .betweenIfPresent(PartnerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PartnerDO::getId));
    }

    default List<PartnerDO> selectList(PartnerExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PartnerDO>()
                .likeIfPresent(PartnerDO::getPartnerName, reqVO.getPartnerName())
                .eqIfPresent(PartnerDO::getPartnerType, reqVO.getPartnerType())
                .eqIfPresent(PartnerDO::getPartnerIntro, reqVO.getPartnerIntro())
                .eqIfPresent(PartnerDO::getPartnerImg, reqVO.getPartnerImg())
                .betweenIfPresent(PartnerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PartnerDO::getId));
    }

    List<CountPartnerRespVO> countPartnerGroupPartnerType();

}
